package com.sl.biz.modular.print.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.sl.biz.modular.print.dao.domain.entity.PrintConfigContentDO;
import com.sl.biz.modular.print.dao.service.PrintConfigContentDaoService;
import com.sl.biz.modular.print.service.PrintConfigContentBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class PrintConfigContentBizServiceImpl implements PrintConfigContentBizService {
    private final PrintConfigContentDaoService printConfigContentDaoService;

    @Override
    public Boolean save(PrintConfigContentDO officeRecord) {

        String printId = officeRecord.getPrintId();
        PrintConfigContentDO printConfigContentDO = new PrintConfigContentDO();
        printConfigContentDO.setPrintId(printId);
        PrintConfigContentDO byOfficeId = getByPrintId(printConfigContentDO);
        if (ObjectUtil.isNotNull(byOfficeId)) {
            officeRecord.setId(byOfficeId.getId());
        }
        return printConfigContentDaoService.saveOrUpdate(officeRecord);
    }

    @Override
    public PrintConfigContentDO getByPrintId(PrintConfigContentDO officeRecordDO) {
        return printConfigContentDaoService.getByPrintId(officeRecordDO.getPrintId());

    }
}
